All Questions
273 questions
1vote
6answers
668views
Bash script that takes multiple path arguments and checks if files can be successfully created there
I would like a bash shell script (for my Debian 12 system) which accepts multiple paths as arguments, and then checks if a file can be successfully created in each one. Then the result should be put ...
0votes
2answers
116views
How to copy the value from one "column" to another in Bash?
I have a file with lines: username="user1" email="[email protected]" I need to take the username from the email address and replace the username value with it, so the end result ...
-1votes
2answers
141views
how to de-duplicate block (timestamp+command) from bash history?
I'm working with bash_history file containing blocks with the following format: #unixtimestamp\ncommand\n here's sample of the bash_history file: #1713308636 cat > ./initramfs/init << "...
-3votes
4answers
140views
Print between two patterns on a single line
I have a file with the following contents: <alarm="yes"> <moduleId>aaa</moduleId> <documentation> <description>bbb</description> <Object>ccc</...
0votes
1answer
740views
How to escape characters inside variables in awk?
I'm trying to make a script that uses awk to get the recent file names from .config/okularrc and pipe them into dmenu, and back to awk to get the path for the name selected. However, I'm getting an ...
1vote
2answers
166views
Combine rows based on shared elements (bash/awk)
I have a following file: a3 v2c v5 a7 a9 v2c v1c a3 a7c Desired output (without duplicates in each row): a3 a7c a9 v1c v2c a7 v5 What I want is to combine the rows sharing at least one element. In ...
0votes
4answers
844views
how to print first word from a string with multiple words without space?
I have a shell script to print appimage filenames inside a folder like this #! /bin/bash Dir="$HOME/Applications/" Dir2="$HOME/Downloads/" cd -P "$Dir" for f in *....
2votes
5answers
434views
AWK reading path from text file
I have a file called path_resume.txt which contains some paths to other files. Inside path_resume.txt: ./a2111oi/sky130_fd_sc_hd__a2111oi_0.txt ./a2111oi/sky130_fd_sc_hd__a2111oi_2.txt ./a2111oi/...
0votes
2answers
115views
Processing a specific part of a text according to pattern from AWK script
Im developing a script in awk to convert a tex document into html, according to my preferences. #!/bin/awk -f BEGIN { FS="\n"; print "<html><body>" } # ...
0votes
3answers
262views
How to print different fields from different lines with AWK
Here is my sample : PING my.host.local (10.10.10.10): 56 data bytes 64 bytes from 10.10.10.10: icmp_seq=0 ttl=63 time=2.034 ms --- my.host.local ping statistics --- 1 packets transmitted, 1 packets ...
0votes
1answer
112views
How to create a sh script that can give as output the exact string I want using the awk command [duplicate]
I would like to have some help writing a script (which should work on FreeBSD where I have sh as default) that should grab a precise string when I do a ps ax | grep bhyve command from the terminal. ...
0votes
0answers
17views
How to returns the correct character after manipulating the output of ps ax | grep [duplicate]
I would like to have some help writing a script (which should works on freebsd where I have sh as default) that should grab a precise character when I do a "ps ax | grep" command from the ...
0votes
1answer
2kviews
Awk replace string where specific condition is true using variables
I am trying to replace a string where a specific condition is true in the same line using awk variables. I found something that could help me a lot but I'm facing a new challenge cause a I need to do ...
0votes
3answers
3kviews
Understanding awk ' NR%2 ... `
Hi I am using 'Bash command line and shell scripts pocket primer' to study bash and I don't understand one chapter of awk, in which they illustrate printing even lines. command: awk ' NR%2 { printf &...
3votes
3answers
6kviews
Output in CSV format using AWK command
I have a input.txt file with following format: Name age number address mark 23 89756342192 chennai david 40 70214789023 delhi How do I create a CSV file from a TXT file as per the ...